<?php
	
	namespace Aspic\Form\Element;
	use Aspic\Security\Security as S;
	
	/**
	* TinyMCE
	*/
	class TinyMCE extends AbstractTextArea {
		protected $_tinyMCEOptions;
	
		public function __construct($name, $label = '', array $tinyMCEOptions = array(), array $options = array(), array $attributes = array()) {
			parent::__construct($name, $label, $options, $attributes);
			
			$tinyMCEOptions['mode'] = 'exact';
			$tinyMCEOptions['elements'] = $this->attr('id');
			
			$this->opt('tinyMCEOptions', $tinyMCEOptions);
		}
		
		public function outJs() {
			$js = '
			
			$(function() {
				tinyMCE.init(
					'.json_encode($this->opt('tinyMCEOptions'), JSON_FORCE_OBJECT).'
				);
			});
			
			';
			
			return parent::outJs().$js;
		}
		
	}	
	
?>